
package ch.hearc.securiteSysteme.serie2.ex3Dictionnaire.use;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

public class Parameters
	{
	
	@Option(name = "-a", usage = "Your chosen alphabet, example : abc457-.", metaVar = "ALPHABET")
	private String m_strAlphabet;
	
	@Option(name = "-min", usage = "Minimum length of a word", metaVar = "MIN")
	private String m_min;
	
	@Option(name = "-max", usage = "Maximum length of a word", metaVar = "MAX")
	private String m_max;
	
	@Option(name = "-o", usage = "Output filename", metaVar = "OUTPUT")
	private String m_o;
	
	public Parameters()
		{
		m_max = null;
		m_min = null;
		m_strAlphabet = null;
		m_o = null;
		}
	
	public String getStrAlphabet()
		{
		return m_strAlphabet;
		}
	
	public String getMin()
		{
		return m_min;
		}
	
	public String getMax()
		{
		return m_max;
		}
	
	public String getOutputFilename()
		{
		return m_o;
		}
	
	public void exec(String[] args) throws CmdLineException
		{
		CmdLineParser parser = new CmdLineParser(this);
		parser.setUsageWidth(80);
		
		parser.parseArgument(args);
		String errorMsg = "UseDictionnaire [-a ALBHABET] [-min MIN] [-max MAX] [-o OUTPUT_FILENAME]";
		if (m_strAlphabet == null)
			{
			throw new CmdLineException(parser, "Alphabet parameter forgotten !\n" + errorMsg);
			}
		else if (m_min == null)
			{
			throw new CmdLineException(parser, "Min parameter forgotten !\n" + errorMsg);
			}
		else if (m_max == null)
			{
			throw new CmdLineException(parser, "Max parameter forgotten !\n" + errorMsg);
			}
		else if (m_o == null) { throw new CmdLineException(parser, "Output filename parameter forgotten !\n" + errorMsg); }
		}
	}
